<?php 

	include('dboper.php');
	
    if(!@$_POST['akses'] == true) {
	   die('Akses langsung tidak diperbolehkan!');
	}

	ob_start(); 
	system("ipconfig /all"); 
	$cominfo=ob_get_contents(); 
	ob_clean(); 
	$search = "Physical";
	$primarymac = strpos($cominfo, $search); 
	$mac=substr($cominfo,($primarymac+36),17);//MAC Address
	
    $d_sistem = getConfig();	
    if($d_sistem['cekIP'] == 'YA' AND $d_sistem['cekMAC'] == 'TIDAK'){
   
       	$query_1 = "SELECT * FROM vote where ip_voter = '".getIP()."' and id_japrak=".$d_sistem['japrak'];
	    $result_1 = mysql_query($query_1) or exit("Error query : <b>".$query_1."</b>.");
		
		while($row=mysql_fetch_row($result_1)){
			$dataregister[] = $row;
			}   

			if(empty($dataregister)) {
				$dataregister = "Null";
			}
	
		echo json_encode($dataregister); 
       
    }  else if($d_sistem['cekIP'] == 'YA' AND $d_sistem['cekMAC'] == 'YA'){

        $query_1 = "SELECT * FROM vote where ip_voter = '".getIP()."' OR mac_voter= '".$mac."'";
	    $result_1 = mysql_query($query_1) or exit("Error query : <b>".$query_1."</b>.");
	
		while($row=mysql_fetch_row($result_1)){
			$dataregister[] = $row;
			}   

			if(empty($dataregister)) {
				$dataregister = "Null";
			}
	
		echo json_encode($dataregister); 
    } else if ($d_sistem['cekIP'] == 'TIDAK' AND $d_sistem['cekMAC'] == 'YA'){
        
        $query_1 = "SELECT * FROM vote where mac_voter= '".$mac."'";
	    $result_1 = mysql_query($query_1) or exit("Error query : <b>".$query_1."</b>.");
	
		while($row=mysql_fetch_row($result_1)){
			$dataregister[] = $row;
			}   

			if(empty($dataregister)) {
				$dataregister = "Null";
			}
	
		echo json_encode($dataregister); 
    } else {
        $query_1 = "SELECT * FROM vote where ip_voter= '-'";
	    $result_1 = mysql_query($query_1) or exit("Error query : <b>".$query_1."</b>.");
	
		while($row=mysql_fetch_row($result_1)){
			$dataregister[] = $row;
			}   

			if(empty($dataregister)) {
				$dataregister = "Null";
			}
	
		echo json_encode($dataregister); 
    }
?>